<template>
	<view>
		<u-navbar title-color="#333" title-bold title-size="36" title="上传照片" :border-bottom="false"></u-navbar>
		<view class="sz-div u-m-t-22 u-p-b-40">
			<view class="u-p-t-22 u-p-b-22">
				<view class="font_16_333 font_weight">
					<span class="xing u-m-r-4">*</span> 请上传照片
				</view>
				<view class="font_12_999 u-m-t-8">
					为确保您上传的图片能清晰显示所有信息，以便工作人员加快审核进度
				</view>
				<view class=" flex flex_wrap u-m-t-28">
					<u-upload width="160" height="160" max-count="1" :form-data="formData" :max-size="1 * 1024 * 1024"
						:action="action" :file-list="fileList" @on-success="onSuccess"></u-upload>
				</view>
			</view>
			<view class="u-m-t-40">
				<view class="font_weight">
					上传要求
				</view>
				<image class="sc-sfz u-m-t-20" src="../../static/img/lawyerVersion/sc-sfz2.png" mode="aspectFill">
				</image>
			</view>
		</view>
		<view class="" style="width: 100%;height: 170rpx;"></view>
		<view class="btn-bo">
			<button class="btn_login_btn" @click="submit">
				提交
			</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				headimg: '',
				// 演示地址，请勿直接使用
				action: '',
				fileList: [],
				images: [],
				type:"",
				formData: {
					token: uni.getStorageSync("token")
				},
			}
		},
		onLoad(e) {
			this.action = this.$config.uploadUrl
			this.type = e.type
			if(this.type==1){
				if(uni.getStorageSync("license_images")){
					this.headimg = uni.getStorageSync("license_images")
					this.fileList.push({url:uni.getStorageSync("license_images")})
				}
			}
			if(this.type==2){
				if(uni.getStorageSync("idcard_images")){
					this.headimg = uni.getStorageSync("idcard_images")
					this.fileList.push({url:uni.getStorageSync("idcard_images")})
				}
			}
			if(this.type==3){
				if(uni.getStorageSync("student_idcard_images")){
					this.headimg = uni.getStorageSync("student_idcard_images")
					this.fileList.push({url:uni.getStorageSync("student_idcard_images")})
				}
			}
			if(this.type==4){
				if(uni.getStorageSync("student_graduate_images")){
					this.headimg = uni.getStorageSync("student_graduate_images")
					this.fileList.push({url:uni.getStorageSync("student_graduate_images")})
				}
			}
		},
		methods: {
			onSuccess(data, index, lists, name) {
				this.headimg = data.data.path
			},
			submit() {
				if(!this.headimg){
					uni.showToast({
						title: "请上传图片",
						icon: "none"
					});
					return
				}
				if(this.type==1){
					uni.setStorage({
						key: 'license_images',
						data: this.headimg
					});
				}
				if(this.type==2){
					uni.setStorage({
						key: 'idcard_images',
						data: this.headimg
					});
				}
				if(this.type==3){
					uni.setStorage({
						key: 'student_idcard_images',
						data: this.headimg
					});
				}
				if(this.type==4){
					uni.setStorage({
						key: 'student_graduate_images',
						data: this.headimg
					});
				}
				
				uni.navigateBack()
			}
		}
	}
</script>

<style scoped lang="scss">
	.xing {
		color: #FF0000;
	}

	.sz-div {
		background-color: #fff;
		width: 686rpx;
		// height: 550rpx;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin: 0 auto;
		padding: 0 24rpx;

		.sc-sfz {
			width: 636rpx;
			height: 144rpx;
		}

	}

	.btn-bo {
		width: 750rpx;
		height: 120rpx;
		background: #FFFFFF;
		box-shadow: 0rpx -2rpx 8rpx 2rpx rgba(0, 0, 0, 0.14);
		padding-top: 14rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 9;

		.btn_login_btn {
			width: 686rpx;
			height: 90rpx;
			background: linear-gradient(180deg, #FA2D2D 0%, #F40000 100%);
			border-radius: 46rpx 46rpx 46rpx 46rpx;
			// margin-top: 116rpx;
			font-size: 36rpx;
			color: #fff;
			line-height: 90rpx;
			margin-left: 32rpx;
			text-align: center;
			font-weight: bold;
		}
	}
</style>